package com.springtest.demo.serices.impl;

import java.util.ArrayList;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.springtest.demo.dao.CourseDao;
import com.springtest.demo.model.Course;
import com.springtest.demo.model.ResultEntity;
import com.springtest.demo.serices.CourseService;

import javax.annotation.Resource;

@Transactional
@Component("courceService")
public class CourseServiceImpl implements CourseService{

	@Resource(name="courseDao")
	private CourseDao courseDao;

	public ResultEntity save(Course c) {
		return ResultEntity.getInstance()
				.setData(courseDao.save(c));
	}

	public ResultEntity update(Course c) {
		return ResultEntity.getInstance()
				.setData(courseDao.update(c));
	}

	public ResultEntity delete(int id) {
		return ResultEntity.getInstance()
				.setData(courseDao.delete(id));
	}

	public ResultEntity delete(Course c) {
		return ResultEntity.getInstance()
				.setData(courseDao.delete(c));
	}

	public ResultEntity findById(int id) {
		return ResultEntity.getInstance()
				.setData(courseDao.findById(id));
	}

	public ResultEntity findAll() {
		return ResultEntity.getInstance()
				.setData(courseDao.findAll());
	}
	

	public ResultEntity page(int page, int size, ArrayList<Object> objs) {
		return ResultEntity.getInstance()
				.setData(courseDao.page(page, size, objs));

	}
	
}
